/**
 * ReportGear(2011)
 */
package com.reportgear.designer.editor.object.pane;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

import com.reportgear.designer.editor.object.DateEditor;
import com.reportgear.designer.editor.object.Editor;
import com.reportgear.designer.editor.object.FormulaEditor;
import com.reportgear.designer.editor.object.NumberEditor;
import com.reportgear.designer.editor.object.TextEditor;
import com.reportgear.designer.editor.object.NoneEditor;
import com.sot.core.util.StringUtils;

/**
 * ValueEditor工厂
 * 
 * @version 1.0 2011-4-27
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class ValueEditorPaneFactory {
	public static ValueEditorPane createValueEditorPane(Editor[] paramArrayOfEditor) {
		return createValueEditorPane(paramArrayOfEditor, null, null);
	}

	public static ValueEditorPane createValueEditorPane(Editor[] paramArrayOfEditor, String paramString1,
			String paramString2) {
		return new ValueEditorPane(paramArrayOfEditor, paramString1, paramString2);
	}

	public static ValueEditorPane createBasicValueEditorPane() {
		return createValueEditorPane(basicEditors(), null, null);
	}

	public static ValueEditorPane createExtendedValueEditorPane() {
		return createValueEditorPane(extendedEditors(), null, null);
	}

	public static ValueEditorPane createURLValueEditorPane(String paramString1, String paramString2) {
		return createValueEditorPane(URLEditors(paramString1, paramString2), null, null);
	}

	public static ValueEditorPane createDateValueEditorPane(String paramString1, String paramString2) {
		return createValueEditorPane(dateEditors(paramString1, paramString2), null, null);
	}

	public static ValueEditorPane createAllValueEditorPane() {
		return createValueEditorPane(allEditors(), null, null);
	}

	public static ValueEditorPane createChartHotValueEditorPane() {
		return createValueEditorPane(chartHotEditors(), null, null);
	}

	public static Editor[] basicEditors() {
		FormulaEditor formulaEditor = new FormulaEditor("公式参数");
		formulaEditor.setEnabled(true);
		return new Editor[] { new TextEditor("字符串"), new NumberEditor(new Integer(1), "整型"),
				new NumberEditor(new Double(1.0D), "浮点型"), new DateEditor(true, "日期型"),
				// new BooleanEditor(Inter.getLocText("Parameter-Boolean")),
				formulaEditor };
	}

	public static Editor[] extendedEditors() {
		// FormulaEditor localFormulaEditor = new
		// FormulaEditor(Inter.getLocText("Parameter-Formula"));
		// localFormulaEditor.setEnabled(true);
		return new Editor[] { new TextEditor("字符串"), new NumberEditor(new Integer(1), "整型"),
				new NumberEditor(new Double(1.0D), "浮点型"), new DateEditor(true, "日期型")
		// new BooleanEditor(Inter.getLocText("Parameter-Boolean")),
		// localFormulaEditor
		// new ParameterEditor(Inter.getLocText("Parameter")), new
		// ColumnRowEditor(Inter.getLocText("Cell"))
		};
	}

	public static Editor[] URLEditors(String paramString1, String paramString2) {
		return new Editor[] {
				new NoneEditor(paramString2, (StringUtils.isEmpty(paramString1)) ? "None" : paramString1),
				new TextEditor("字符串") };
	}

	public static Editor[] dateEditors(String paramString1, String paramString2) {
		return new Editor[] {
				new NoneEditor(paramString2, (StringUtils.isEmpty(paramString1)) ? "None" : paramString1),
				new DateEditor(true, "日期") };
	}

	public static Editor[] allEditors() {
		// FormulaEditor localFormulaEditor = new
		// FormulaEditor(Inter.getLocText("Parameter-Formula"));
		// localFormulaEditor.setEnabled(true);
		return new Editor[] { new TextEditor("字符串"), new NumberEditor(new Integer(1), "整型"),
				new NumberEditor(new Double(1.0D), "浮点型"), new DateEditor(true, "日期型")

		// new BooleanEditor(Inter.getLocText("Parameter-Boolean")),
		// localFormulaEditor,
		// new ParameterEditor(Inter.getLocText("Parameter")), new
		// ColumnRowEditor(Inter.getLocText("Cell")),
		// new DSColumnEditor(Inter.getLocText("DataColumn"))

		};
	}

	public static Editor[] chartHotEditors() {
		// FormulaEditor localFormulaEditor1 = new
		// FormulaEditor(Inter.getLocText("CategoryName"));
		// localFormulaEditor1.setEnabled(true);
		// localFormulaEditor1.setValue(new Formula("CATEGORY"));
		// FormulaEditor localFormulaEditor2 = new
		// FormulaEditor(Inter.getLocText("ChartF-Series_Name"));
		// localFormulaEditor2.setEnabled(true);
		// localFormulaEditor2.setValue(new Formula("SERIES"));
		// FormulaEditor localFormulaEditor3 = new
		// FormulaEditor(Inter.getLocText("Chart-Series_Value"));
		// localFormulaEditor3.setEnabled(true);
		// localFormulaEditor3.setValue(new Formula("VALUE"));
		// FormulaEditor localFormulaEditor4 = new
		// FormulaEditor(Inter.getLocText("Parameter-Formula"));
		// localFormulaEditor4.setEnabled(true);
		return new Editor[] {// localFormulaEditor1, localFormulaEditor2,
								// localFormulaEditor3,
		new TextEditor("字符串"), new NumberEditor(new Integer(1), "整型"), new NumberEditor(new Double(1.0D), "浮点型"),
				new DateEditor(true, "日期型") };
	}

	public static JPanel createKeyAndValuePane(ValueEditorPane paramValueEditorPane1,
			ValueEditorPane paramValueEditorPane2) {
		JPanel localJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel localJPanel2 = new JPanel(new BorderLayout());
		localJPanel1.add(localJPanel2);
		localJPanel2.add(new JLabel(" 值:"), BorderLayout.NORTH);
		localJPanel2.add(paramValueEditorPane1, BorderLayout.CENTER);
		JPanel localJPanel3 = new JPanel(new BorderLayout());
		localJPanel1.add(localJPanel3);
		localJPanel3.add(new JLabel("显示值:"), BorderLayout.NORTH);
		localJPanel3.add(paramValueEditorPane2, BorderLayout.CENTER);
		return localJPanel1;
	}
}